package utils;

import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;

import java.io.*;
import java.util.List;

/**
 * @author: dm
 * @date: 2023/1/31 14:06
 * @description:
 */
public class WordUtils {
    /**
     * word转pdf
     * @param wordPath
     * @param target
     */
    public static void wordToPdf(String wordPath, String target) {
        try (FileInputStream is = new FileInputStream(wordPath);
             FileOutputStream pdf = new FileOutputStream(target);
        ) {
            XWPFDocument xwpfDocument = new XWPFDocument(is);
            PdfOptions pdfOptions = PdfOptions.create();
            PdfConverter.getInstance().convert(xwpfDocument, pdf, pdfOptions);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    
}
